home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: 500 MB Amiga Software / 500 MB Amiga Software - Euber 130 - Amiga Games Disc & Mag.iso / userbox / publicdomain / tinymeter / source / tinymeter_prefs / volumes.c < prev   
C/C++ Source or Header  |  1995-08-30  |  2KB  |  82 lines

  1. #include <dos/dos.h>
  2. #include <dos/dosextens.h>
  3.  
  4. char    *LoadedVolList[256];
  5. char    *VolList[256];
  6.  
  7. loadsavedvols()
  8. {
  9.     UBYTE   *my_file;
  10.     int     i=0;
  11.     char    temp_str[255];
  12.     int     j=0;
  13.  
  14.     my_file=(UBYTE *)Open("ENV:TinyMeter_Volumes",MODE_OLDFILE);
  15.     if(my_file)
  16.     {
  17.         while( FGets(my_file,&temp_str[0],255L) )
  18.         {
  19.             LoadedVolList[j]=(char *)malloc(255L);
  20.             i=0;
  21.             while(temp_str[i]!=0)
  22.             {
  23.                 if(temp_str[i]==10)
  24.                 {
  25.                     temp_str[i]=0;
  26.                     break;
  27.                 }
  28.                 i++;
  29.             }
  30.             strcpy((char *)LoadedVolList[j],(char *)&temp_str[0]);
  31.             j++;
  32.         }
  33.         LoadedVolList[j]=0L;
  34.         Close(my_file);
  35.     }
  36. }
  37.  
  38. getsystemvols()
  39. {
  40.     struct DosList  *dl=0L;
  41.     struct InfoData  inf;
  42.     struct DevProc  *devproc;
  43.     char            *poke;
  44.     char             my_str[256];
  45.     int              j=0,p=0;
  46.  
  47.     dl = (struct DosList *)LockDosList(LDF_VOLUMES|LDF_DEVICES|LDF_READ);
  48.     if(dl)
  49.     {
  50.         while ((dl = (struct DosList *) NextDosEntry(dl,LDF_VOLUMES|LDF_DEVICES)) )
  51.         {
  52.             if(dl->dol_Task)
  53.             {
  54.                 BtoCStr(&my_str[0],dl->dol_Name,254L);
  55.                 strcat(my_str,":");
  56.                 VolList[j]=(ULONG)malloc(256L);
  57.                 strcpy((char *)VolList[j],my_str);
  58.                 j++;
  59.             }
  60.         }
  61.         UnLockDosList(LDF_VOLUMES|LDF_DEVICES|LDF_READ);
  62.     }
  63.     VolList[j]=(ULONG)0L;
  64. }
  65.  
  66. freevols()
  67. {
  68.     ULONG df=0L;
  69.     while(VolList[df])
  70.     {
  71.         free(VolList[df]);
  72.         df++;
  73.     }
  74.     df=0L;
  75.     while(LoadedVolList[df])
  76.     {
  77.         free(LoadedVolList[df]);
  78.         df++;
  79.     }
  80. }
  81.  
  82.